home *** CD-ROM | disk | FTP | other *** search
- Path: news.ov.com!news
- From: glenn@ov.com (Fletcher.Glenn@ov.com)
- Newsgroups: comp.lang.c
- Subject: Re: HELP: system() exit status
- Date: 12 Apr 1996 15:42:36 GMT
- Organization: OpenVision
- Message-ID: <4kltlc$7mc@spanky.pls.ov.com>
- References: <4kk8m6$omb@news.accent.net>
- Reply-To: glenn@ov.com
- NNTP-Posting-Host: foghorn.pls.ov.com
-
- In article omb@news.accent.net, dallaire@megatoon.com (Guy Dallaire) writes:
- >Hi,
- >
- >I have a program which does a lot of "system()" calls here. Is it
- >safe to assume that ANY return code other than 0 (on a UNIX) system
- >means that the command specified as a parameter to system() did dot
- >work ?
- >
- >NOTE: I also checked for -1 which indicates that system() could not
- >spawn the command.
- >
- >Also: Most man pages do not explicitly state what return status one
- >can expect after calling some system call/utility. For example, it's
- >not stated that the `cp` command exits with value x, y, or z depending
- >on the case where the source file is not present, the destination file
- >is write protect, anmd so on. Can was assume that any return status of
- >0 means that all went well and anything else means there has been an
- >error ?
- >
- >That question always puzzled me...
- >
- > Thanks !
- >
- >P.S.: Please reply by e-mail also
- >
-
-
- It would have been better to post this to comp.unix.programmer.
-
- A system() call returns a union __wait as defined in <sys/wait.h>.
- In a sparc system, this basically boils down to the lower two bytes
- of an int containing the following values:
- The higher byte contains the "exit" value from the indicated command.
- The lower byte contains the number of the signal that terminated
- the indicated command (if any). A zero means no signal.
-
- Fletcher.Glenn@ov.com
-
-
-